<?php
#include("connect.php")

$query = "SELECT name, link, bplay FROM video_manager";
$Result = mysql_query($query);
$numrow = mysql_num_rows($Result);

if( $numrow != 0 ) {
	$i = 0;
	while ($row = mysql_fetch_assoc($Result) ) {
		$name = $row['name'];
		$link = $row['link'];
		$play = $row['bplay'];
		
		// filetype of videos that are uploaded.
		if ($link != ".." && $link != ".") {
			
			if (substr($link, -5) == ".webm" || substr($link, -4) == ".ogv" || substr($link, -4) == ".mp4") {
			switch(substr($link, -4)) {
				case ".ogv":
					$type = "video/ogg";
				break;
				case ".mp4":
					$type = "video/mp4";
				break;
				default:
					$type = "video/webm";
				break;
			}	
	
			if( $play != 0 ) {
				print('<div class="videobox"><h2>'.substr(str_replace("_", " ", $link), 0, -5).'</h2><div class="video"><div class="video-js-box"><br/><video 		                   id="video_'.$i.'" height="480" width="640" class="video-js" controls="controls" preload="false"><source src="'.$link.'"/></video></div>');					
				$i++;
			}		
			} else if( substr($link, -4) == '.flv') {
				echo 'can not play this type';	
			}
		}
	}
}
?>